package tpf.designer.pattern.course6.behavior_pattern1.homework.exercise1;

import java.sql.ResultSet;
import java.sql.SQLException;

public class PartDb extends CommonDb<Part> {

    private static final String SQL_SELECT_PARTS = "select * from part";

    @Override
    protected Part createEntityFromResultSet(ResultSet rs) throws SQLException {
        Part p = new Part();
        p.setName(rs.getString("name"));
        p.setBrand(rs.getString("brand"));
        p.setRetailPrice(rs.getDouble("retail_price"));
        return p;
    }

    @Override
    protected String getSelectEntitySql() {
        return SQL_SELECT_PARTS;
    }
}